-- buy_reagent
-- created by panyl
-- 冈布奥事件：购买试剂

-- 购买商场物品
EventMgr.register("buy_reagent", event.BUY_GOODS, function(para)
    local goodsId = para.goodsId;

    -- 商品基本信息
    local dbase = MarketM.query(goodsId, "dbase") or {};

    if dbase["slime_event"] ~= "buy_reagent" then
        -- 不是该子规则关注的事件
        return;
    end

    -- 先增加进度
    SlimeEventM.addProgress("buy_reagent");

    local arr = SlimeEventM.getIdsByRule("buy_reagent");
    for index = 1, #arr do
        SlimeEventM.triggerEvent(arr[index]);
    end
end);

return {
    triggerEvent = function(eventId, para)
        -- 如果是试剂类的
        local bonus = SlimeEventM.calcEventBonus(eventId, para);
        if type(bonus) == "table" and
            bonus["reagent_id"] then
            return true;
        end

        return false;
    end,
};

